package com.demo.common.core.converter;

import org.springframework.core.convert.converter.Converter;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

/**
 * localDate入参格式化
 *
 * @author DayDayUp
 * @datetime 2023-08-31 10:18
 **/
public class LocalDateConverter implements Converter<String, LocalDate> {

    private final DateTimeFormatter dateTimeFormatter;

    public LocalDateConverter(DateTimeFormatter dateTimeFormatter) {
        this.dateTimeFormatter = dateTimeFormatter;
    }

    @Override
    public LocalDate convert(String source) {
        return LocalDate.parse(source, dateTimeFormatter);
    }
}
